.class public Lcom/opongo/blogapp/activities/SearchActivity;
.super Lcom/opongo/blogapp/activities/AbstractPostsListActivity;
.source "SearchActivity.java"


# static fields
.field public static final DEBUG:Z

.field private static final TAG:Ljava/lang/String;


# instance fields
.field private cat_parent:I


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 19
    sget-boolean v0, Lcom/opongo/blogapp/AbaSettings;->DEBUG:Z

    sput-boolean v0, Lcom/opongo/blogapp/activities/SearchActivity;->DEBUG:Z

    .line 20
    const-class v0, Lcom/opongo/blogapp/activities/SearchActivity;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/opongo/blogapp/activities/SearchActivity;->TAG:Ljava/lang/String;

    .line 17
    return-void
.end method

.method public constructor <init>()V
    .locals 1

    .prologue
    .line 17
    invoke-direct {p0}, Lcom/opongo/blogapp/activities/AbstractPostsListActivity;-><init>()V

    .line 21
    const/4 v0, -0x1

    iput v0, p0, Lcom/opongo/blogapp/activities/SearchActivity;->cat_parent:I

    .line 17
    return-void
.end method

.method private handleIntent(Landroid/content/Intent;)V
    .locals 3
    .parameter "intent"

    .prologue
    .line 62
    const-string v1, "android.intent.action.SEARCH"

    invoke-virtual {p1}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 63
    const-string v1, "query"

    invoke-virtual {p1, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 64
    .local v0, query:Ljava/lang/String;
    sget-boolean v1, Lcom/opongo/blogapp/activities/SearchActivity;->DEBUG:Z

    if-eqz v1, :cond_0

    sget-object v1, Lcom/opongo/blogapp/activities/SearchActivity;->TAG:Ljava/lang/String;

    invoke-static {v1, v0}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 66
    :cond_0
    invoke-virtual {p0, v0}, Lcom/opongo/blogapp/activities/SearchActivity;->doSearch(Ljava/lang/String;)V

    .line 68
    .end local v0           #query:Ljava/lang/String;
    :cond_1
    return-void
.end method


# virtual methods
.method protected doSearch(Ljava/lang/String;)V
    .locals 1
    .parameter "search"

    .prologue
    .line 71
    iput-object p1, p0, Lcom/opongo/blogapp/activities/SearchActivity;->searchString:Ljava/lang/String;

    .line 72
    const/4 v0, 0x1

    invoke-virtual {p0, v0}, Lcom/opongo/blogapp/activities/SearchActivity;->doRefresh(Z)V

    .line 73
    return-void
.end method

.method public onCreate(Landroid/os/Bundle;)V
    .locals 8
    .parameter "savedInstanceState"

    .prologue
    const/4 v5, 0x0

    const/4 v7, -0x1

    .line 26
    sget-boolean v0, Lcom/opongo/blogapp/activities/SearchActivity;->DEBUG:Z

    if-eqz v0, :cond_0

    .line 27
    sget-object v0, Lcom/opongo/blogapp/activities/SearchActivity;->TAG:Ljava/lang/String;

    const-string v1, "*** create ***"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 29
    :cond_0
    new-instance v2, Lcom/opongo/blogapp/manager/DatabaseManager;

    .line 30
    const-string v0, "search_posts"

    const-string v1, "INSERT INTO search_posts (id,title,date,content,categories,commentscount,imageurl,post_order,guid,opened,newpost,did_vote,post_author,post_price,post_rating) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"

    .line 29
    invoke-direct {v2, p0, v0, v1}, Lcom/opongo/blogapp/manager/DatabaseManager;-><init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V

    .line 32
    .local v2, dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;
    const-string v0, "DELETE FROM search_posts"

    invoke-virtual {v2, v0}, Lcom/opongo/blogapp/manager/DatabaseManager;->execQuery(Ljava/lang/String;)V

    .line 34
    const-string v3, "SELECT * FROM search_posts ORDER BY date DESC"

    .line 37
    .local v3, query:Ljava/lang/String;
    const/4 v4, 0x0

    move-object v0, p0

    move-object v1, p1

    invoke-super/range {v0 .. v5}, Lcom/opongo/blogapp/activities/AbstractPostsListActivity;->onCreate(Landroid/os/Bundle;Lcom/opongo/blogapp/manager/DatabaseManager;Ljava/lang/String;ILcom/opongo/blogapp/manager/APIManager;)V

    .line 38
    const v0, 0x7f030014

    invoke-virtual {p0, v0}, Lcom/opongo/blogapp/activities/SearchActivity;->setContentView(I)V

    .line 41
    invoke-virtual {p0}, Lcom/opongo/blogapp/activities/SearchActivity;->getIntent()Landroid/content/Intent;

    move-result-object v0

    invoke-virtual {v0}, Landroid/content/Intent;->getExtras()Landroid/os/Bundle;

    move-result-object v6

    .line 44
    .local v6, extras:Landroid/os/Bundle;
    if-eqz v6, :cond_1

    .line 46
    const-string v0, "CAT_PARENT"

    invoke-virtual {v6, v0, v7}, Landroid/os/Bundle;->getInt(Ljava/lang/String;I)I

    move-result v0

    iput v0, p0, Lcom/opongo/blogapp/activities/SearchActivity;->cat_parent:I

    .line 49
    :cond_1
    iget v0, p0, Lcom/opongo/blogapp/activities/SearchActivity;->cat_parent:I

    if-ne v0, v7, :cond_2

    .line 50
    invoke-virtual {p0}, Lcom/opongo/blogapp/activities/SearchActivity;->getIntent()Landroid/content/Intent;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/opongo/blogapp/activities/SearchActivity;->handleIntent(Landroid/content/Intent;)V

    .line 53
    :goto_0
    return-void

    .line 52
    :cond_2
    invoke-virtual {p0, v5}, Lcom/opongo/blogapp/activities/SearchActivity;->doSearch(Ljava/lang/String;)V

    goto :goto_0
.end method

.method protected onNewIntent(Landroid/content/Intent;)V
    .locals 0
    .parameter "intent"

    .prologue
    .line 57
    invoke-virtual {p0, p1}, Lcom/opongo/blogapp/activities/SearchActivity;->setIntent(Landroid/content/Intent;)V

    .line 58
    invoke-direct {p0, p1}, Lcom/opongo/blogapp/activities/SearchActivity;->handleIntent(Landroid/content/Intent;)V

    .line 59
    return-void
.end method
